/* Basic AJAX functionality */

function getDataReturnXML(url, callback, obj)
{
	var XMLHttpRequestObject = getXMLHttpRequestObject();

	if(XMLHttpRequestObject) {
		XMLHttpRequestObject.open("GET", url);
		
		XMLHttpRequestObject.onreadystatechange = function() {
			if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
				callback(XMLHttpRequestObject.responseXML, obj);
				delete XMLHttpRequestObject;
				XMLHttpRequestObject = null;
			}
		}

		XMLHttpRequestObject.send(null);
	}
}

function postDataReturnXML(url, data, callback, obj)
{
	var XMLHttpRequestObject = getXMLHttpRequestObject();
	
	if(XMLHttpRequestObject) {
		XMLHttpRequestObject.open("POST", url);
		XMLHttpRequestObject.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		
		XMLHttpRequestObject.onreadystatechange = function() {
			if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
				callback(XMLHttpRequestObject.responseXML, obj);
				delete XMLHttpRequestObject;
				XMLHttpRequestObject = null;
			}
		}

		XMLHttpRequestObject.send(data);
	}
}

function postDataReturnText(url, data, callback, obj)
{
	var XMLHttpRequestObject = getXMLHttpRequestObject();
	
	if(XMLHttpRequestObject) {
		XMLHttpRequestObject.open("POST", url);
		XMLHttpRequestObject.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		
		XMLHttpRequestObject.onreadystatechange = function() {
			if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
				callback(XMLHttpRequestObject.responseText, obj);
				delete XMLHttpRequestObject;
				XMLHttpRequestObject = null;
			}
		}

		XMLHttpRequestObject.send(data);
	}
}

function getXMLHttpRequestObject() {
	var XMLHttpRequestObject = false;

	if (window.XMLHttpRequest) {
		XMLHttpRequestObject = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
	}

	return XMLHttpRequestObject;
}

function testXMLHttpObject() {
	var XMLHttpRequestObject = getXMLHttpRequestObject();
	var result = (XMLHttpRequestObject != false);
	delete XMLHttpRequestObject;
	XMLHttpRequestObject = null;
	return result;	
}